<?php
namespace Home\Controller;
use Think\Controller;
use Think\Page;

class FoodController extends CommonController {
	private $article_model;

	public function _initialize(){
		parent::_initialize();

		$this->article_model = M('Article');
	}


	public function index(){

		$this->cafeteria();
	}

	public function cafeteria(){
		$template_parms = array(
      'action' => __FUNCTION__
		);

		$this->common_food(58,$template_parms);
	}

	public function coffee(){
		$template_parms = array(
      'action' => __FUNCTION__
		);

		$this->common_food(70,$template_parms);
	}

	public function common_food($article_id,$template_parms){
		$article = $this->article_model->find($article_id);
		$article = $this->check_EN_ZH($article);

		$photo = M('Photos');
		$photolist = $photo->where('is_small=1 and photoable_id='.$article_id)->order('created_at desc')->select();
		foreach ($photolist as $k => $v ){
			$bigpath = $photo->where('id='.$v['parent_id'])->getField('path');
			$photolist[$k]['bigpath'] = $bigpath;
		}
		
		$this->assign('photo_list',$photolist);

		if(empty($template_parms['name']))
       		$template_parms['name'] = 'index';
		$this->assign('template_parms',$template_parms);
		
		$this->assign('article',$article);
		$this->display('Food/index');
	}
}